home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / sound / squarewave / squarewavesynthplay.c < prev   
Encoding:
C/C++ Source or Header  |  2000-09-28  |  1.8 KB  |  82 lines

  1. /*
  2.     File:        SquareWaveSynthPlay.c
  3.  
  4.     Contains:    Plays a sound using the squareWaveSynth.
  5.                 Sets the timbre with timbreCmd
  6.                 Starts playing with the freqCmd
  7.  
  8.     Written by: Brigham Stevens    
  9.  
  10.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  11.  
  12.                 You may incorporate this Apple sample source code into your program(s) without
  13.                 restriction. This Apple sample source code has been provided "AS IS" and the
  14.                 responsibility for its operation is yours. You are not permitted to redistribute
  15.                 this Apple sample source code as "Apple sample source code" after having made
  16.                 changes. If you're going to re-distribute the source, we require that you make
  17.                 it clear in the source that the code was descended from Apple sample source
  18.                 code, but that you've made changes.
  19.  
  20.     Change History (most recent first):
  21.                 7/29/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  22.                 
  23.  
  24. */
  25. #include <Dialogs.h>
  26. #include <Sound.h>
  27.  
  28. void SquareWaveSynthPlay();
  29.  
  30. void SquareWaveSynthPlay()
  31. {
  32.     SndChannelPtr    chan;
  33.     SndCommand        mycmd;
  34.     unsigned long    count;
  35.     short            change = 0;
  36.     short            err;
  37.     
  38.     
  39.     /* Allocate a channel tied to the squareWaveSynth */
  40.     chan = nil;
  41.     err = SndNewChannel (&chan, squareWaveSynth, 0, nil);
  42.     if (err) {
  43.         DebugStr("\p error SndNewChannel [2]");
  44.         goto bail;
  45.     }
  46.     
  47.     mycmd.cmd = freqCmd;
  48.     mycmd.param1 = 0;
  49.     mycmd.param2 = 50;
  50.     
  51.     err = SndDoImmediate (chan, &mycmd);
  52.     if (err) {
  53.         DebugStr("\p error SndDoImmediate [3]");
  54.         goto bail;
  55.     }
  56.         
  57.     mycmd.cmd = timbreCmd;
  58.     mycmd.param1 = 0;
  59.     mycmd.param2 = 86;
  60.     
  61.     err = SndDoImmediate (chan, &mycmd);
  62.     if (err) {
  63.         DebugStr("\p error SndDoImmediate [3]");
  64.         goto bail;
  65.     }
  66.     
  67.     Delay (180, &count);
  68.         
  69.     err = SndDisposeChannel (chan,false);
  70.     if (err) {
  71.         DebugStr("\p error SndDisposeChannel [2]");
  72.         goto bail;
  73.     }
  74. bail:
  75.     return;
  76. }
  77.  
  78.  
  79. void main()
  80. {
  81.     SquareWaveSynthPlay();
  82. }